/**
 * com.dingjian.basedata.service.impl.DataEntityService.java
 */
package com.dingjian.basedata.service.impl;

import java.util.Date;

import com.dingjian.base.service.impl.BaseServiceImpl;
import com.dingjian.basedata.DataEntity;
import com.dingjian.basedata.util.SystemUtil;

/**
 * @author FengMy
 * 
 * @since 2012-9-17
 */
public abstract class DataEntityService<T extends DataEntity> extends BaseServiceImpl<T> {
	
	@Override
	public void addEntity(T entity) {
		if(entity!=null){
			entity.setCreateTime(new Date());
			entity.setCreator(SystemUtil.getCurrentUser());
			entity.setControlUnit(SystemUtil.getCurrentControlUnit());
			entity.setOrg(SystemUtil.getCurrentOrg());
		}
		super.addEntity(entity);
	}
	
	@Override
	public void updateEntity(T entity) {
		if(entity!=null){
			entity.setLastUpdateTime(new Date());
			entity.setUpdator(SystemUtil.getCurrentUser());
		}
		super.updateEntity(entity);
	}
}
